﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace ESLReminder
{
    public class GameModuleCollection : PluginCollection<GameModule>
    {
        public GameModuleCollection(IReminderInterface host)
            : base(host)
        {
            //create default modules
            LoadPlugins(this.GetType().Assembly);
        }
        public GameModule GetRunningGame()
        {
            foreach (GameModule g in m_LoadedPlugins)
            {
                Process[] processes = Process.GetProcessesByName(g.ProcessName);
                if (processes.Length > 0)
                {
                    g.ProcessStarted(processes[0]);
                    return g;
                }
            }
            return null;
        }
        public GameModule GetGameForProcess(Process proc)
        {
            GameModule[] modules = LoadedPlugins;
            foreach (GameModule g in modules)
            {
                if (g.isGame(proc))
                    return g;
            }
            return null;
        }
    }
}
